import Vue from 'vue'
import axios from 'axios'

const baseurl = 'https://scmapi.56yhz.com/'
const axiosInstance = axios.create({
  baseURL: baseurl,
  timeout: 5000
})

axiosInstance.interceptors.request.use(
  function (config) {
    return config
  },
  function (error) {
    return Promise.reject(error)
  }
)

axiosInstance.interceptors.response.use(
  function (response) {
    return response
  },
  function (error) {
    return Promise.reject(error)
  }
)

function post (url, data) {
  return axiosInstance.post(url, data)
}

Vue.prototype.$axios = axiosInstance

export { post }
